<template>
	<view class="service-evaluation" v-if="lawyerEvaluationList">
		<view class="service-evaluation-title">
			服务评价
		</view>
		<view class="service-evaluation-main">
			<view class="lawyer-service-score-container">
				<view class="service-score">
					<view class="value">
						{{serviceScore.score}}
					</view>
					<view class="label">
						综合评分
					</view>
				</view>
				<view class="evaluation-count">
					<view class="value">
						{{lawyerEvaluationList.total}} <text class="unit">个</text>
					</view>
					<view class="label">
						用户评价
					</view>
				</view>
			</view>
			<view class="user-evaluation-container" v-for="item,index in lawyerEvaluationList.data" :key="index">
				<view class="user-evaluation-top-container">
					<view class="user-info-wrapper">
						<view class="user-avatar">
							<u-image width="100%" height="100%" border-radius="50%" :src="item.customerinfo.avatars" />
						</view>
						<view class="user-info-right">
							<view class="user-name">
								{{item.customerinfo.nickname}}
							</view>
							<view class="user-phone">
								{{item.customerinfo.phone}}
							</view>
						</view>
					</view>
					<view class="evaluation-date">
						{{item.created_at}}
					</view>
				</view>
				<view class="user-evaluation-score-container">
					<u-rate :count="5" :value="item.score" disabled active-color="#fcd165" /><text
						class="score">{{item.score}}分</text>
				</view>
				<view class="user-evaluation-content-container">
					{{item.remark?item.remark:'该用户没有留下评语'}}
				</view>
				<view class="reply-list-wrapper" v-if="replyList[index].length">
						<view class="reply-item" v-for="replyItem,replyIndex in replyList[index]" :key="replyItem.id">
							<text class="sender-name">{{replyItem.form_nickname}}回复{{replyItem.to_nickname}}:</text>
							<text class="reply-content">{{replyItem.remark}}</text>
						</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	// var replyList = []
	export default {
		props: {
			lawyerEvaluationList: {
				type: Object
			},
			serviceScore: {
				type: Object
			}
		},
		data(){
			return {
				replyList:[],
			}
		},
		mounted() {
			// this.$nextTick(() => {
			for (let item of this.lawyerEvaluationList.data) {
				let tmp = [];
				this.getReplyList(item, tmp);
				// this.$set(item, 'replyList', tmp);
				this.replyList.push(tmp)
			}
			console.log(this.replyList)
			// console.log(this.lawyerEvaluationList.data)
			// })
		},
		watch: {
			lawyerEvaluationList: {
				handler(val) {
					if (val) {
						
					}
				}
			}
		},
		methods: {
			getReplyList(data, tmp) {
				console.log(data.evaluate_reply && data.evaluate_reply.length > 0)
				if (!data.evaluate_reply || !data.evaluate_reply.length) {
					return
				}
				for (let item of data.evaluate_reply) {
					tmp.push(item);
					this.getReplyList(item, tmp);
				}
			}
		}
	}
</script>

<style scoped lang="scss">
	@import "./serviceEvaluation.scss";
</style>
